from langchain.schema import BaseOutputParser
import re


class CommaSeparatedListOutputParser(BaseOutputParser):
    """Parse the output of an LLM call to a comma-separated list."""

    def parse(self, text: str):
        """Parse the output of an LLM call."""
        # return text.strip().split(r", ")
        return re.split(r',\s*', text)


xres = CommaSeparatedListOutputParser().parse("Rinoa, Fiona, Cynthia, Jane, and Kate")
print(xres)
